package com.etime.shyauth.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.etime.shyauth.pojo.SysFunction;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 系统功能管理dao接口
 */
@Repository
public interface SysFunctionMapper extends BaseMapper<SysFunction> {
    /**
     * 查询登录用户所能使用的功能权限
     * @param userid 用户id
     * @return 登录用户所具有的权限
     */
    @Select(" select distinct a.funid,funpid,funurl,funname,funtype,funicon " +
            " from sysfunction a inner join sysroleright b on a.funid=b.funid" +
            " where a.funtype in (0,1,2) and funstate=1 and b.roleid in (select roleid from sysuserrole where userid=#{userid})")
    List<SysFunction> selectUserFunction(@Param("userid") Integer userid);

    /**
     * 查询超级管理员所能使用的权限列表（所有的功能都能使用）
     * @return
     */
    @Select("select a.funid,funpid,funname,funurl,funtype,funicon from sysfunction a where  a.funtype in (0,1,2) and funstate=1 ")
    List<SysFunction> selectAdminFunction();
}
